package com.king.juc.n8.jucdemo.aqs;

import lombok.extern.slf4j.Slf4j;

import static com.king.juc.utils.ThreadUtil.sleep;

/**
 * @author king
 * @date 2020/12/12 21:12
 */
@Slf4j(topic = "c.AqsTest")
public class AqsTest {
    public static void main(String[] args) {
        MyLock lock = new MyLock();
        new Thread(() -> {
            lock.lock();
            try {
                log.debug("locking...");
                sleep(1);
            }finally {
                log.debug("unlocking...");
                lock.unlock();
            }
        }, "t1").start();

        new Thread(() -> {
            lock.lock();
            try {
                log.debug("locking...");
                sleep(1);
            }finally {
                log.debug("unlocking...");
                lock.unlock();
            }
        }, "t2").start();
    }
}
